﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ZP.DTO.Common
{
    [Serializable]
    /// <summary>
    /// 当前登录用户信息
    /// </summary>
    public class UserLoginDTO
    {
        /// <summary>
        /// 用户ID
        /// </summary>
        public int id { get; set; }
        /// <summary>
        /// 账户名称
        /// </summary>
        public string account { get; set; }
        /// <summary>
        /// 账户密码
        /// </summary>
        public string password { get; set; }
        /// <summary>
        /// 角色ID
        /// </summary>
        public int? roleId { get; set; }
        /// <summary>
        /// 角色名称
        /// </summary>
        public string roleName { get; set; }
        /// <summary>
        /// 职工
        /// </summary>
        public int? employeeId { get; set; }
        /// <summary>
        /// 更新人
        /// </summary>
        public string updater { get; set; }
        /// <summary>
        /// 更新时间
        /// </summary>
        public DateTime? updateTime { get; set; }
        /// <summary>
        /// 账号是否删除
        /// </summary>
        public int? state { get; set; }

        /// <summary>
        /// 账号是否锁住
        /// </summary>
        public int? isLocked { get; set; }

        public DateTime? lockTime { get; set; }
        /// <summary>
        /// 用户头像
        /// </summary>
        public string headImg { get; set; }

        public fz_base_employee.fz_base_employeeResultDTO employee { get; set; }

        /// <summary>      
        /// <summary>
        /// 当前用户自定义权限
        /// </summary>
        public List<CurrentUserAuthority> CurrentUserAuthorityList { get; set; }
        /// <summary>
        /// 当前用户权限列表
        /// </summary>
        public List<CurrentAuthorityDTO> CurrentAuthorityList
        {
            get
            {
                List<CurrentAuthorityDTO> result = new List<CurrentAuthorityDTO>();
                List<CurrentAuthorityDTO> TempResult = new List<CurrentAuthorityDTO>();

                if (CurrentUserAuthorityList != null)
                {
                    CurrentUserAuthorityList.ForEach(g =>
                    {
                        TempResult.Add(new CurrentAuthorityDTO { id = g.id, name = g.name });
                    });
                }

                CurrentAuthorityDTO cadto = null;
                foreach (var p in TempResult)
                {
                    cadto = result.Where(g => g.id == p.id).FirstOrDefault();
                    if (cadto == null)
                    {
                        result.Add(new CurrentAuthorityDTO { id = p.id, name = p.name });
                    }
                    else
                    {
                        cadto.name = p.name;
                    }
                }
                return result;
            }
        }

        public class CurrentUserAuthority
        {
            /// <summary>
            /// 菜单名称
            /// </summary>
            public string name { get; set; }
            /// <summary>
            /// 菜单权限ID
            /// </summary>
            public int id { get; set; }
            /// <summary>
            /// 父节点
            /// </summary>
            public int upId { get; set; }
            /// <summary>
            /// 菜单链接
            /// </summary>
            public string path { get; set; }
            public string iconClass { get; set; }
            public int isLeaf { get; set; }
        }
        /// <summary>
        /// 当前权限
        /// </summary>
        public class CurrentAuthorityDTO
        {
            /// <summary>
            /// 菜单名称
            /// </summary>
            public string name { get; set; }
            /// <summary>
            /// 菜单权限ID
            /// </summary>
            public long id { get; set; }
        }

    }

    public class AccountLoginDTO
    {
        public string Account { get; set; }
        public string Password { get; set; }
    }
    public class PortalUserLoginDTO
    {
        public int user_id { get; set; }
        public int type { get; set; }
        public string account { get; set; }
        public string password { get; set; }
        public string name { get; set; }
        //public int ep_id = user_id { get; set; } 
        //public int is_delete { get; set; }

    }
    /// <summary>
    /// 登录信息
    /// </summary>
    /*public class LoginDTO
    {
        /// <summary>
        /// 手机号
        /// </summary>
        public string PhoneNumber { get; set; }
        /// <summary>
        /// 动态密码
        /// </summary>
        public string DynamicPassword { get; set; }
    }*/
}
